#include "includes.h"
#include "pcf8563.h"
#include "datetime.h"

#define DEV_NAME "pcf8563"

RTC_Device pcf8563;

static TDateTime  tmp = {
	2012,
	04,
	16,
	15,
	45,
	20
};
static bool pcf8563_get_datetime(TDateTime *dt)
{
	if(dt){
		if( tmp.sec++ >= 60) tmp.sec = 0;

		memcpy(dt,&tmp,sizeof(TDateTime));
		
		return true;
	}
	return false;
}
static bool pcf8563_set_datetime(TDateTime *dt)
{
	if(dt){
	
		memcpy(&tmp,dt,sizeof(TDateTime));
		
		return true;
	}
	return false;
}

static int rtc_pcf8563_init()
{
	
	memset(&pcf8563, 0 , sizeof(RTC_Device));
	
	strncpy(pcf8563.name,DEV_NAME,MAX_RTC_DEV_NAME);
	
	pcf8563.get_datetime = pcf8563_get_datetime;
	pcf8563.set_datetime = pcf8563_set_datetime;
	
	register_rtc(&pcf8563);
	return 1;
}
//device_initcall(rtc_pcf8563_init);

